<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 薪资报表数据表
 *
 * Date: 2018/6/12
 * @author George
 */
class CreateWagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wages', function (Blueprint $table) {
            $table->increments('id');
			$table->year('year')->index()->comment('年');
			$table->string('month')->index()->comment('月');
            $table->unsignedInteger('company_id')->index()->comment('公司ID');
			$table->unsignedInteger('social_security_id')->default(0)->comment('社保设置ID');
			$table->string('social_security_name')->nullable()->comment('社保名称');
			$table->unsignedInteger('user_id')->comment('用户ID');
			$table->unsignedInteger('user_name')->comment('用户姓名');
			$table->string('identification', 18)->nullable()->unique()->comment('身份证');
			$table->timestamp('hiredate_at')->nullable()->comment('入职时间');
			$table->date('expiry')->nullable()->comment('合同到期日期');
			$table->string('department_name')->nullable()->comment('部门名称');
			$table->string('position_name')->nullable()->comment('岗位名称');
			$table->unsignedInteger('pattern_id')->index()->comment('方案ID');
			$table->string('pattern_name')->comment('方案名称');
			$table->unsignedInteger('attendance_days')->default(0)->comment('总出勤日');
			$table->unsignedInteger('holidays')->default(0)->comment('总出勤日');
			$table->json('custom_fields')->comment('自定义字段');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wages');
    }
}
